\hypertarget{classdev_1_1net_1_1_event_loop}{}\section{dev\+:\+:net\+:\+:Event\+Loop Class Reference}
\label{classdev_1_1net_1_1_event_loop}\index{dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}}


事件循环  




{\ttfamily \#include $<$Event\+Loop.\+hpp$>$}

Inheritance diagram for dev\+:\+:net\+:\+:Event\+Loop\+:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{classdev_1_1net_1_1_event_loop}
\end{center}
\end{figure}
\subsection*{Public Types}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classdev_1_1net_1_1_event_loop_a48a02756ae182b1e704e6e33350a9025}{}enum {\bfseries Status} \{ {\bfseries R\+E\+A\+D\+Y}, 
{\bfseries R\+U\+N\+N\+I\+N\+G}, 
{\bfseries E\+X\+I\+T\+I\+N\+G}, 
{\bfseries E\+X\+I\+T}
 \}\label{classdev_1_1net_1_1_event_loop_a48a02756ae182b1e704e6e33350a9025}

\item 
\hypertarget{classdev_1_1net_1_1_event_loop_aa6a61f420ff2236c2f039cfa35c49c08}{}typedef boost\+::function$<$ void(\hyperlink{classdev_1_1net_1_1_socket}{Socket} $\ast$)$>$ {\bfseries Pass\+Socket\+Pointer\+C\+B}\label{classdev_1_1net_1_1_event_loop_aa6a61f420ff2236c2f039cfa35c49c08}

\end{DoxyCompactItemize}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classdev_1_1net_1_1_event_loop_adaa82e1b594ab036bf4a2fb0ebbf8482}{}{\bfseries Event\+Loop} (\hyperlink{classdev_1_1net_1_1_reactor}{Reactor} $\ast$rector)\label{classdev_1_1net_1_1_event_loop_adaa82e1b594ab036bf4a2fb0ebbf8482}

\item 
\hypertarget{classdev_1_1net_1_1_event_loop_aabaaf8e05a0862f12d5ab65fcf772633}{}int \hyperlink{classdev_1_1net_1_1_event_loop_aabaaf8e05a0862f12d5ab65fcf772633}{run} (void)\label{classdev_1_1net_1_1_event_loop_aabaaf8e05a0862f12d5ab65fcf772633}

\begin{DoxyCompactList}\small\item\em 执行事件循环 \end{DoxyCompactList}\item 
\hypertarget{classdev_1_1net_1_1_event_loop_a2115323b7b33ddab22e986c64c2741a8}{}void \hyperlink{classdev_1_1net_1_1_event_loop_a2115323b7b33ddab22e986c64c2741a8}{stop} (void)\label{classdev_1_1net_1_1_event_loop_a2115323b7b33ddab22e986c64c2741a8}

\begin{DoxyCompactList}\small\item\em 停止事件循环 \end{DoxyCompactList}\item 
void \hyperlink{classdev_1_1net_1_1_event_loop_a065de9a81bafe581317bd49536afbf6a}{queue\+Event} (boost\+::function$<$ void(void)$>$ handler)
\begin{DoxyCompactList}\small\item\em 在事件循环执行这个函数 \end{DoxyCompactList}\item 
void \hyperlink{classdev_1_1net_1_1_event_loop_ac6a263ce319c3be4036cc621d3a4e254}{add\+Socket} (\hyperlink{classdev_1_1net_1_1_socket}{Socket} $\ast$sock, Reactor\+::\+Event\+Type events, \hyperlink{classdev_1_1net_1_1_socket_event_handler}{Socket\+Event\+Handler} $\ast$handler)
\begin{DoxyCompactList}\small\item\em 绑定套接字到事件循环，事件循环会负责检查这个套接字上的事件并派发 \end{DoxyCompactList}\item 
void \hyperlink{classdev_1_1net_1_1_event_loop_ab198f9ccb0bdd9722e300970ba522371}{remove\+Socket} (\hyperlink{classdev_1_1net_1_1_socket}{Socket} $\ast$sock)
\begin{DoxyCompactList}\small\item\em 从事件循环移除这个套接字 \end{DoxyCompactList}\item 
Status \hyperlink{classdev_1_1net_1_1_event_loop_afeeb886d08c61f513723581a4462c7a7}{get\+Status} (void) const 
\begin{DoxyCompactList}\small\item\em 获取事件循环状态 \end{DoxyCompactList}\item 
Reactor\+Ptr \& \hyperlink{classdev_1_1net_1_1_event_loop_a3cc34cdad07de13a6612fdc7dd660cbf}{get\+Reactor} (void)
\begin{DoxyCompactList}\small\item\em 获取事件循环的网络反应器 \end{DoxyCompactList}\item 
base\+::mtime\+\_\+t \hyperlink{classdev_1_1net_1_1_event_loop_a5c0413d7e832d1da05e0a19d2c0b3d59}{get\+Frame\+Time} (void) const 
\begin{DoxyCompactList}\small\item\em 获取事件循环的帧时间 \end{DoxyCompactList}\item 
void \hyperlink{classdev_1_1net_1_1_event_loop_a0d109507f05fa7e25e25c8786c765daf}{set\+Frame\+Time} (base\+::mtime\+\_\+t time)
\begin{DoxyCompactList}\small\item\em 设置事件循环的帧时间 \end{DoxyCompactList}\item 
int \hyperlink{classdev_1_1net_1_1_event_loop_a8e1fef09fb4c03dd0ee629e700aa6e67}{get\+Id} (void) const 
\begin{DoxyCompactList}\small\item\em 获取事件循环的\+I\+D \end{DoxyCompactList}\item 
unsigned long long \hyperlink{classdev_1_1net_1_1_event_loop_a6a7dc03f144ed38d10b40547922501a3}{get\+Loop\+Counter} (void) const 
\begin{DoxyCompactList}\small\item\em 获取事件循环已经循环的次数 \end{DoxyCompactList}\item 
base\+::mtime\+\_\+t \hyperlink{classdev_1_1net_1_1_event_loop_ac5e0b8420fd73e47c2b806135893abb7}{get\+Frame\+System\+Time} (void) const 
\begin{DoxyCompactList}\small\item\em 获取事件循环当前执行一帧消耗的时间 \end{DoxyCompactList}\item 
void \hyperlink{classdev_1_1net_1_1_event_loop_aa12ef12c8efa905621d3f9d834cd1f19}{set\+Remove\+Socket\+Callback} (Pass\+Socket\+Pointer\+C\+B callback)
\begin{DoxyCompactList}\small\item\em 设置事件循环套接字移除回调函数，当完成移除这个套接字时会调用 \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Friends}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classdev_1_1net_1_1_event_loop_a0736aba6eec2f2c2a13494228473b67c}{}class {\bfseries Tcp\+Worker}\label{classdev_1_1net_1_1_event_loop_a0736aba6eec2f2c2a13494228473b67c}

\item 
\hypertarget{classdev_1_1net_1_1_event_loop_a3ecf3132e8c4bf890c07853cfab7619c}{}class {\bfseries Tcp\+Server}\label{classdev_1_1net_1_1_event_loop_a3ecf3132e8c4bf890c07853cfab7619c}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
事件循环 

\subsection{Member Function Documentation}
\hypertarget{classdev_1_1net_1_1_event_loop_ac6a263ce319c3be4036cc621d3a4e254}{}\index{dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}!add\+Socket@{add\+Socket}}
\index{add\+Socket@{add\+Socket}!dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}}
\subsubsection[{add\+Socket(\+Socket $\ast$sock, Reactor\+::\+Event\+Type events, Socket\+Event\+Handler $\ast$handler)}]{\setlength{\rightskip}{0pt plus 5cm}void Event\+Loop\+::add\+Socket (
\begin{DoxyParamCaption}
\item[{{\bf Socket} $\ast$}]{sock, }
\item[{Reactor\+::\+Event\+Type}]{events, }
\item[{{\bf Socket\+Event\+Handler} $\ast$}]{handler}
\end{DoxyParamCaption}
)}\label{classdev_1_1net_1_1_event_loop_ac6a263ce319c3be4036cc621d3a4e254}


绑定套接字到事件循环，事件循环会负责检查这个套接字上的事件并派发 


\begin{DoxyParams}{Parameters}
{\em sock} & 套接字指针 \\
\hline
{\em events} & 注册到这个套接字的事件 \\
\hline
{\em handelr} & 事件处理器 \\
\hline
\end{DoxyParams}
\hypertarget{classdev_1_1net_1_1_event_loop_ac5e0b8420fd73e47c2b806135893abb7}{}\index{dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}!get\+Frame\+System\+Time@{get\+Frame\+System\+Time}}
\index{get\+Frame\+System\+Time@{get\+Frame\+System\+Time}!dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}}
\subsubsection[{get\+Frame\+System\+Time(void) const }]{\setlength{\rightskip}{0pt plus 5cm}base\+::mtime\+\_\+t dev\+::net\+::\+Event\+Loop\+::get\+Frame\+System\+Time (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}\label{classdev_1_1net_1_1_event_loop_ac5e0b8420fd73e47c2b806135893abb7}


获取事件循环当前执行一帧消耗的时间 

\begin{DoxyReturn}{Returns}
base\+::mtime\+\_\+t 
\end{DoxyReturn}
\hypertarget{classdev_1_1net_1_1_event_loop_a5c0413d7e832d1da05e0a19d2c0b3d59}{}\index{dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}!get\+Frame\+Time@{get\+Frame\+Time}}
\index{get\+Frame\+Time@{get\+Frame\+Time}!dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}}
\subsubsection[{get\+Frame\+Time(void) const }]{\setlength{\rightskip}{0pt plus 5cm}base\+::mtime\+\_\+t dev\+::net\+::\+Event\+Loop\+::get\+Frame\+Time (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}\label{classdev_1_1net_1_1_event_loop_a5c0413d7e832d1da05e0a19d2c0b3d59}


获取事件循环的帧时间 

\begin{DoxyReturn}{Returns}
base\+::mtime\+\_\+t 
\end{DoxyReturn}
\hypertarget{classdev_1_1net_1_1_event_loop_a8e1fef09fb4c03dd0ee629e700aa6e67}{}\index{dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}!get\+Id@{get\+Id}}
\index{get\+Id@{get\+Id}!dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}}
\subsubsection[{get\+Id(void) const }]{\setlength{\rightskip}{0pt plus 5cm}int dev\+::net\+::\+Event\+Loop\+::get\+Id (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}\label{classdev_1_1net_1_1_event_loop_a8e1fef09fb4c03dd0ee629e700aa6e67}


获取事件循环的\+I\+D 

\begin{DoxyReturn}{Returns}
int 
\end{DoxyReturn}
\hypertarget{classdev_1_1net_1_1_event_loop_a6a7dc03f144ed38d10b40547922501a3}{}\index{dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}!get\+Loop\+Counter@{get\+Loop\+Counter}}
\index{get\+Loop\+Counter@{get\+Loop\+Counter}!dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}}
\subsubsection[{get\+Loop\+Counter(void) const }]{\setlength{\rightskip}{0pt plus 5cm}unsigned long long dev\+::net\+::\+Event\+Loop\+::get\+Loop\+Counter (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}\label{classdev_1_1net_1_1_event_loop_a6a7dc03f144ed38d10b40547922501a3}


获取事件循环已经循环的次数 

\begin{DoxyReturn}{Returns}
unsigned long long 
\end{DoxyReturn}
\hypertarget{classdev_1_1net_1_1_event_loop_a3cc34cdad07de13a6612fdc7dd660cbf}{}\index{dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}!get\+Reactor@{get\+Reactor}}
\index{get\+Reactor@{get\+Reactor}!dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}}
\subsubsection[{get\+Reactor(void)}]{\setlength{\rightskip}{0pt plus 5cm}Reactor\+Ptr\& dev\+::net\+::\+Event\+Loop\+::get\+Reactor (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{classdev_1_1net_1_1_event_loop_a3cc34cdad07de13a6612fdc7dd660cbf}


获取事件循环的网络反应器 

\begin{DoxyReturn}{Returns}
Reactor\+Ptr 
\end{DoxyReturn}
\hypertarget{classdev_1_1net_1_1_event_loop_afeeb886d08c61f513723581a4462c7a7}{}\index{dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}!get\+Status@{get\+Status}}
\index{get\+Status@{get\+Status}!dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}}
\subsubsection[{get\+Status(void) const }]{\setlength{\rightskip}{0pt plus 5cm}Status dev\+::net\+::\+Event\+Loop\+::get\+Status (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}\label{classdev_1_1net_1_1_event_loop_afeeb886d08c61f513723581a4462c7a7}


获取事件循环状态 

\begin{DoxyReturn}{Returns}
Status 
\end{DoxyReturn}
\hypertarget{classdev_1_1net_1_1_event_loop_a065de9a81bafe581317bd49536afbf6a}{}\index{dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}!queue\+Event@{queue\+Event}}
\index{queue\+Event@{queue\+Event}!dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}}
\subsubsection[{queue\+Event(boost\+::function$<$ void(void)$>$ handler)}]{\setlength{\rightskip}{0pt plus 5cm}void Event\+Loop\+::queue\+Event (
\begin{DoxyParamCaption}
\item[{boost\+::function$<$ void(void)$>$}]{handler}
\end{DoxyParamCaption}
)}\label{classdev_1_1net_1_1_event_loop_a065de9a81bafe581317bd49536afbf6a}


在事件循环执行这个函数 


\begin{DoxyParams}{Parameters}
{\em handler} & 需要执行的函数 \\
\hline
\end{DoxyParams}
\hypertarget{classdev_1_1net_1_1_event_loop_ab198f9ccb0bdd9722e300970ba522371}{}\index{dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}!remove\+Socket@{remove\+Socket}}
\index{remove\+Socket@{remove\+Socket}!dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}}
\subsubsection[{remove\+Socket(\+Socket $\ast$sock)}]{\setlength{\rightskip}{0pt plus 5cm}void Event\+Loop\+::remove\+Socket (
\begin{DoxyParamCaption}
\item[{{\bf Socket} $\ast$}]{sock}
\end{DoxyParamCaption}
)}\label{classdev_1_1net_1_1_event_loop_ab198f9ccb0bdd9722e300970ba522371}


从事件循环移除这个套接字 


\begin{DoxyParams}{Parameters}
{\em sock} & 套接字指针 \\
\hline
\end{DoxyParams}
\hypertarget{classdev_1_1net_1_1_event_loop_a0d109507f05fa7e25e25c8786c765daf}{}\index{dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}!set\+Frame\+Time@{set\+Frame\+Time}}
\index{set\+Frame\+Time@{set\+Frame\+Time}!dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}}
\subsubsection[{set\+Frame\+Time(base\+::mtime\+\_\+t time)}]{\setlength{\rightskip}{0pt plus 5cm}void dev\+::net\+::\+Event\+Loop\+::set\+Frame\+Time (
\begin{DoxyParamCaption}
\item[{base\+::mtime\+\_\+t}]{time}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{classdev_1_1net_1_1_event_loop_a0d109507f05fa7e25e25c8786c765daf}


设置事件循环的帧时间 


\begin{DoxyParams}{Parameters}
{\em time} & 帧时间 \\
\hline
\end{DoxyParams}
\hypertarget{classdev_1_1net_1_1_event_loop_aa12ef12c8efa905621d3f9d834cd1f19}{}\index{dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}!set\+Remove\+Socket\+Callback@{set\+Remove\+Socket\+Callback}}
\index{set\+Remove\+Socket\+Callback@{set\+Remove\+Socket\+Callback}!dev\+::net\+::\+Event\+Loop@{dev\+::net\+::\+Event\+Loop}}
\subsubsection[{set\+Remove\+Socket\+Callback(\+Pass\+Socket\+Pointer\+C\+B callback)}]{\setlength{\rightskip}{0pt plus 5cm}void dev\+::net\+::\+Event\+Loop\+::set\+Remove\+Socket\+Callback (
\begin{DoxyParamCaption}
\item[{Pass\+Socket\+Pointer\+C\+B}]{callback}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{classdev_1_1net_1_1_event_loop_aa12ef12c8efa905621d3f9d834cd1f19}


设置事件循环套接字移除回调函数，当完成移除这个套接字时会调用 


\begin{DoxyParams}{Parameters}
{\em callback} & 回调函数 \\
\hline
\end{DoxyParams}


The documentation for this class was generated from the following files\+:\begin{DoxyCompactItemize}
\item 
dev/dev/net/Event\+Loop.\+hpp\item 
dev/src/net/Event\+Loop.\+cpp\end{DoxyCompactItemize}
